﻿layui.use('layer', function () {
    var $ = layui.$;
    var layer = layui.layer;
    var util = layui.util;
    var form = layui.form;
    var table = layui.table;

    ///添加
    var list = {
        deliveryName: '',
        deliveryNumber: '',
        deliveryDate: '',
        orderNumber: '',
        remark: '',
        finishedProductName: '',
        finishedProductNumber: '',
        specification: '',
        unit: '',
        productionNumber: '',
        outboundQuantity: '',
        warehouseName: '',
        dateTime: '',
        warehousePerson: ''
    };
    form.on('submit(demo-ddd)', function (data) {
        list.deliveryName = $("#deliveryName").val();
        list.deliveryNumber = $("#deliveryNumber").val();
        list.deliveryDate = $("#deliveryDate").val();
        list.orderNumber = $("#orderNumber").val();
        list.remark = $("#remark").val();
        list.finishedProductName = $("#finishedProductName").val();
        list.finishedProductNumber = $("#finishedProductNumber").val();
        list.unit = $("#unit").val();
        list.specification = $("#specification").val();
        list.productionNumber = $("#productionNumber").val();
        list.outboundQuantity = $("#outboundQuantity").val();
        list.warehouseName = $("#warehouseName").val();
        list.dateTime = $("#dateTime").val();
        list.warehousePerson = $("#warehousePerson").val();
        $.ajax({
            url: '/Delivery/DeliveryAdd',
            type: 'post',
            data: { data: JSON.stringify(list), token: localStorage.getItem("token") },
            success: function (res) {
                var s = JSON.parse(res)
                console.log(res)
                if (s.data >= 1) {
                    layer.alert("添加成功");
                    setTimeout(function () {
                        window.location.href = "/Delivery/DeliveryShowView";
                    }, 2000);
                }
                else {
                    layer.alert("添加失败");
                }
            }
        })
        return false; // 阻止默认 form 跳转

    })
});
